﻿@using CSM_SQL;
@using System.Configuration;
@model List<OrderMes>
<section class="shopping-cart">
    <!-- .shopping-cart -->
    <div class="container">
        <div class="row">
            <div class="col-md-12">

            </div>
            <hr />
            <div class="col-md-12">
                <br />
                <hr />
                <div class="row">
                    <div class="title">
                        <h2>
                            评价
                        </h2>
                        <ul class="nav nav-tabs etabs">
                            <li class="active"><a data-toggle="tab" href="#e1">待评价</a></li>
                            <li><a data-toggle="tab" href="#e2">已评价</a></li>
                        </ul>
                    </div>
                    <div class="tab-content">
                        <div id="e1" class="tab-pane fade in active">
                            <table>
                                <tr>

                                    <th></th>
                                    
                                    <th>产品名</th>
                                    <th>数量</th>
                                    <th>送货员</th>
                                    <th>签收时间</th>
                                    <th>订单评价</th>

                                    <th>说明</th>
                                    <th></th>
                                </tr>
                                @foreach (var m in Model.Where(a => a.assess == null))
                                {
                                    var path = ConfigurationManager.AppSettings["path"].ToString() + m.goods.Img;
                                    <tr>
                                        <td><img src=@path alt="13" width="100"></td>
                                        <td>@m.goods.Name</td>
                                        <td>@m.order.Amount</td>

                                        <td><strong>@m.postName</strong></td>
                                        <td>@m.order.EndTime</td>
                                        <td>
                                            <select class="selected" style="width:inherit" name="@m.order.ID">
                                                <option value="5">极好</option>
                                                <option value="4">好</option>
                                                <option value="3">一般</option>
                                                <option value="2">差</option>
                                                <option value="1">太烂了</option>
                                            </select>
                                        </td>

                                        <td><textarea name="@m.order.ID" rows="3"></textarea></td>
                                        <td><a href="javascript:void(0)" name="@m.order.ID" onclick="postAssess(@m.order.ID,this)">提交</a></td>
                                    </tr>
                                }



                            </table>
                        </div>
                        <div id="e2" class="tab-pane fade in">
                            <table>
                                <tr>

                                    <th></th>
                                    <th>产品名</th>
                                    <th>数量</th>
                                    <th>送货员</th>
                                    <th>签收时间</th>
                                    <th>订单评价</th>
                                    <th>说明</th>
                                    <th></th>
                                </tr>
                                @foreach (var m in Model.Where(a => a.assess != null))
                                {
                                    var path = ConfigurationManager.AppSettings["path"].ToString() + m.goods.Img;
                                    <tr>
                                        <td><img src=@path alt="13" width="100"></td>
                                        <td>@m.goods.Name</td>
                                        <td>@m.order.Amount</td>
                                        <td><strong>@m.postName</strong></td>
                                        <th>@m.order.EndTime</th>
                                        <td>
                                            <div class="star2">

                                                <ul>
                                                    @{var i = 0; }
                                                    @for (i = 0; i < m.assess.Grade; i++)
                                                    {
                                                        <li class="yellow-color"><i class="fa fa-star" aria-hidden="true"></i></li>
                                                    }

                                                    @for (; i < 5; i++)
                                                    {
                                                        <li><i class="fa fa-star" aria-hidden="true"></i></li>
                                                    }


                                                </ul>
                                            </div>
                                        </td>

                                        <td><p> @m.assess.Assess1</p></td>

                                    </tr>
                                }

                            </table>
                        </div>
                    </div>


                </div>
            </div>

        </div>
        <!-- /.shopping-cart -->

    </div>
</section>
<script>
    function postAssess(id, obj) {
        var a = obj.name
        var grade = $("[name='" + a + "']").eq(0).val();
        var txt = $("[name='" + a + "']").eq(1).val();

        $.ajax({
            type: 'post',
            url: '/Home/PostAssess',
            data: {'id':id,'grade':grade,'txt':txt},
            success: function (data) {
                window.location.reload();
            }
        });
    }

    //$(".q").click(function () {

    //    if ($(this).attr("c") == 0) {

    //        var a = $(".yellow-color:last");
    //        a.removeClass("yellow-color");
    //        a.addClass("blank");
    //        a.attr("c", 1);
    //    }
    //    else {

    //        var b = $(".blank:first");
    //        b.attr("c", 0);
    //        b.addClass("yellow-color");
    //        b.removeClass("blank");
    //    }
    //});
</script>

